package com.xxxx.paipaicars.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by frank on 2023/2/17.
 */
@SuppressWarnings("all")
@Configuration
public class ExecutorSerserviceConfig {
    @Bean
    public ExecutorService taskExecutor() {
        // 创建的一个线程池
        ExecutorService executorService = new ThreadPoolExecutor(
                Runtime.getRuntime().availableProcessors(),// 核心线程数
                Runtime.getRuntime().availableProcessors() * 2,// 最大线程数
                60,// 存活时间
                TimeUnit.MILLISECONDS,// 存活时间单位
                new LinkedBlockingQueue<Runnable>(200));// 队列

        return executorService;
    }
}
